package com.base.factory.factorymethod;


import com.base.factory.factorymethod.factory.ComputerFactory;
import com.base.factory.factorymethod.factory.impl.AsusFactory;
import com.base.factory.factorymethod.factory.impl.DellFactory;
import com.base.factory.factorymethod.factory.impl.ThinkPadFactory;

/**
 * Created by xingyuchao on 2017-06-17.
 * 测试工厂方法
 */
public class Main {
    public static void main(String[] args) {
        //工厂方法模式
        //各个产品的生产商，都有自己的工厂
        //生产工艺，生产的流程都是不一样的
        //对于用户来说，现在必须知道使用哪个工厂，也不太合理，增加了代码的复杂度

        ComputerFactory computerFactory = new AsusFactory();
        System.out.println(computerFactory.getComputer().getBrand());

        computerFactory = new DellFactory();
        System.out.println(computerFactory.getComputer().getBrand());

        computerFactory = new ThinkPadFactory();
        System.out.println(computerFactory.getComputer().getBrand());
    }
}
